package polygon.cli.util;

import polygon.util.impl.PostParameter;
import polygon.util.impl.UnsafeFileUtil;
import polygon.util.FileUtil;
import polygon.util.ZipUtil;

import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * @author MikeMirzayanov (mirzayanovmr@gmail.com)
 */
public class DownloadUtil {
    public static String download(URL url, String login, String password) throws IOException {
        PostParameter[] postParameters = new PostParameter[2];
        postParameters[0] = new PostParameter("login", login);
        postParameters[1] = new PostParameter("password", password);
        byte[] bytes = UnsafeFileUtil.downloadFileAsByteArray(url.toString(),
                Integer.MAX_VALUE, postParameters);
        return new String(bytes, "UTF-8");
    }
}
